package com.limao.servlet;

import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.dom4j.DocumentException;

import com.Hazelcast.CacheFactory;
import com.Szjcyh.Until.Api;
import com.Szjcyh.Until.QueryJWModelData;
import com.Szjcyh.Until.QueryModel;
import com.Szjcyh.Until.ResultModel;
import com.alibaba.fastjson.JSON;
import com.corefire.config.CorefireConfig;
import com.corefire.util.MD5;
import com.corefire.util.SignUtils;
import com.corefire.util.XmlUtils;
import com.limao.CacheManager.BaseDataCacheManager;
import com.limao.CacheManager.CrowdHomeCommendCache;
import com.limao.CacheManager.CrowdOrderCache;
import com.limao.CacheManager.CrowdSysCateCache;
import com.limao.CacheManager.CrowdSysProjectCache;
import com.limao.CacheManager.CrowdUserAuthCache;
import com.limao.CacheManager.CrowdVRHomeCache;
import com.limao.CacheManager.sys_AdvCacheManager;
import com.limao.DBDataClass.AdvDataClass;
import com.limao.DBDataClass.CrowdHomeCommendClass;
import com.limao.DBDataClass.CrowdOrderDataClass;
import com.limao.DBDataClass.CrowdSysProjectClass;
import com.limao.DBDataClass.CrowdUserAuthClass;
import com.limao.DBDataClass.CrowdVRHomeClass;
import com.limao.DBDataClass.SysProjectCateDataClass;
import com.limao.DBProvider.CrowdOrderProvider;
import com.limao.DBProvider.CrowdUserAuthProvider;
import com.limao.DbConnection.DbConnectionManager;
import com.limao.Model.LzPluginException;
import com.limao.Model.PublicData;
import com.limao.Tool.CacheClass;
import com.limao.Utils.vrsysrmb;
import com.unionpay.acp.demo.DemoBase;
import com.unionpay.acp.sdk.AcpService;
import com.unionpay.acp.sdk.SDKConfig;

public class WebFunction {

	/**系统是否维护中**/
	public static String SysIspaused()
	{
		if(CacheClass.getIntValue(CacheClass.getSYS_BaseDataCacheManager().Load_Param("ispaused"))==1)
		{
			if(CacheClass.Maintenance_Start_time==0) 
				CacheClass.Maintenance_Start_time=CacheClass.getTime();
			int timel=CacheClass.getIntValue(CacheClass.getSYS_BaseDataCacheManager().Load_Param("pausedtime"));
			return "系统维护中,维护开始时间："+CacheClass.getFormatDate(CacheClass.Maintenance_Start_time,"yyyy-MM-dd hh:mm:ss")+"，维护时长约"+timel+"分钟";
		}
		else
			CacheClass.Maintenance_Start_time=0;
		return null;
	}
	/**web首页广告**/
	public static List<AdvDataClass> getHomeAdv() 
	{
		return sys_AdvCacheManager.getInstance().Load_SysHomeAdv();
	}
	
	/**web众筹项目种类**/
	public static List<SysProjectCateDataClass> getProjectCate() 
	{
		return CrowdSysCateCache.getInstance().loadProjectCateJson();
	}	
	
	/**web首页推荐内容**/
	public static List<CrowdHomeCommendClass> getHomeCommend() 
	{
		return CrowdHomeCommendCache.getInstance().Load_CrowdHomeCommend_All();
	}

	
	/**某众筹的主页 **/
	public static CrowdSysProjectClass getProjectInfo(String projectid) 
	{
		if(CacheClass.isEmpty(projectid))
		{
			return null;
		}
		return CrowdSysProjectCache.getInstance().load_Goods_Info_ById(CacheClass.getIntValue(projectid));

	}

	/**某众筹的话题列表 分页 **/
	public static PublicData getProjeChatInfo(String projectid,String curpage) 
	{
		if(CacheClass.isEmpty(projectid))
		{
			return null;
		}
		if(CacheClass.isEmpty(curpage))
		{
			curpage="0";
		}
		try {
			return CrowdSysProjectCache.getInstance().load_Goods_Discuss_ById(CacheClass.getIntValue(projectid),CacheClass.getIntValue(curpage));
		} catch (LzPluginException e) {
			e.printStackTrace();
		}
		return null;
	}	
	
	/**某众筹的支持者列表 分页 **/
	public static PublicData getProjectBuyUserInfo(String projectid,String curpage) 
	{
		if(CacheClass.isEmpty(projectid))
		{
			return null;
		}
		if(CacheClass.isEmpty(curpage))
		{
			curpage="0";
		}
		try {
			return CrowdSysProjectCache.getInstance().load_Goods_Buy_ById(CacheClass.getIntValue(projectid),CacheClass.getIntValue(curpage));
		} catch (LzPluginException e) {
			e.printStackTrace();
		}
		return null;
	}	
	
	
	/**取某众筹某个套餐详细信息 **/
	public static CrowdSysProjectClass getPacketInfo(String projectid) 
	{
		if(CacheClass.isEmpty(projectid))
		{
			return null;
		}
		return CrowdSysProjectCache.getInstance().load_Goods_Info_ById(CacheClass.getIntValue(projectid));

	}
	


	/**取个人详细信息 **/
	public static CrowdUserAuthClass getUserInfo(HttpServletRequest request,HttpServletResponse response) 
	{
		String useridStr=CacheClass.isLogin(request,response);
		if(CacheClass.isEmpty(useridStr))
		{
			return null;
		}
		int userid=CacheClass.getIntValue(useridStr);

		return CrowdUserAuthCache.getInstance().getUser(userid);

	}
	public static CrowdUserAuthClass getUserInfo(String useridStr) 
	{
		if(CacheClass.isEmpty(useridStr))
		{
			return null;
		}
		int userid=CacheClass.getIntValue(useridStr);

		return CrowdUserAuthCache.getInstance().getUser(userid);

	}
	
	/**取个人MD5后密码 **/
	public static String getUserPwd(HttpServletRequest request,HttpServletResponse response) 
	{
		
		String useridStr=CacheClass.isLogin(request,response);
		if(CacheClass.isEmpty(useridStr))
		{
			return null;
		}
		
		//开通交易帐户
		try {
			CrowdUserAuthProvider.getInstance().openAuthForTradeUser(useridStr);
		} catch (LzPluginException e) {
			e.printStackTrace();
		}
		
		
		int userid=CacheClass.getIntValue(useridStr);

		return CrowdUserAuthCache.getInstance().getPwdMd5(userid);

	}
	


	
	/**取理财 公司详细信息 **/
	public static CrowdVRHomeClass getVrHomeInfo(HttpServletRequest request,HttpServletResponse response) 
	{
		String userid=CacheClass.isLogin(request,response);
		if(CacheClass.isEmpty(userid))
		{
			return null;
		}

		return CrowdVRHomeCache.getInstance().Load_CrowdVR();

	}
	
	
	/**取某订单 详细信息 **/
	public static CrowdOrderDataClass getCrowdOrderInfo(HttpServletRequest request,HttpServletResponse response,String orderidStr) 
	{
		String userid=CacheClass.isLogin(request,response);
		if(CacheClass.isEmpty(userid))
		{
			return null;
		}

		int orderid = CacheClass.getIntValue(orderidStr);
		return CrowdOrderCache.getInstance().loadOrderByID(orderid);

	}

	/**产生模拟用户  产生100个  1000<userid<2000  并设定999999999金额值**/
	public static void CreateUserInfo(HttpServletRequest request,HttpServletResponse response) 
	{
		int userid=1001;
		for(int i=0;i<100;i++)
		{
			try {
				CrowdUserAuthProvider.getInstance().createUsernmae2(userid+i,(15911110000l+(userid+i))+"", "e10adc3949ba59abbe56e057f20f883e", "");
			} catch (LzPluginException e) {
				e.printStackTrace();
			}
		}

		return ;

	}	
	
	/**模拟用户  是否进行市场交易开关**/
	public static void SetUserTrade(HttpServletRequest request,HttpServletResponse response,String flag) 
	{
		int openFlag =CacheClass.getIntValue(flag);
		
		if(openFlag==1)
		{
			CacheClass.istrade=true;
		}
		else
		{
			CacheClass.istrade=false;
		}

		return ;

	}	
	
	
	/**模拟用户  是否进行市场交易开关**/
	public static void SetUserTradeOpen(HttpServletRequest request,HttpServletResponse response,String flag,String ratToHigh,String debug) 
	{
		int openFlag =CacheClass.getIntValue(flag);
		
		CacheClass.priceToHigh=CacheClass.getFloatValue(ratToHigh);
		if(openFlag==1)
		{
			CacheClass.istrade=true;
		}
		else
		{
			CacheClass.istrade=false;
		}
		
		CacheClass.ISDEBUG=CacheClass.getIntValue(debug);
		
		return ;

	}

	

	
	/**手动执行 定时任务  进行众筹订单与委单的  检查处理**/
	public static void AutoCheckCdOrder(){
		
		Calendar orderTime = Calendar.getInstance();
		orderTime.setTime(new Date());
		orderTime.set(Calendar.HOUR_OF_DAY, 0);
		orderTime.set(Calendar.MINUTE, 0);
		orderTime.set(Calendar.SECOND, 0);  
		orderTime.set(Calendar.MILLISECOND, 0);
		Date orderDate = orderTime.getTime();
		
		//清除所有缓存
		CacheFactory.clearHazelcastAllCache();
		//设置服务器维护中
		BaseDataCacheManager.getInstance().Set_Param("pausedtime", "20"); //维护时长，显示给用户看的
		BaseDataCacheManager.getInstance().Set_Param("ispaused", "1");  //设置为维护中
		
		
		
		CrowdOrderCache.getInstance().AutoCheckCdOrder(orderDate);
		
		
		//完成后 服务器 恢复正常
		BaseDataCacheManager.getInstance().ClearObjectCache("pausedtime");
		BaseDataCacheManager.getInstance().ClearObjectCache("ispaused"); 
	}
	
	/** 银联支付web  **/
	public static Map<String, String> toUnionPayCdOrder(HttpServletRequest request,HttpServletResponse response,String orderid){
		
		Map<String, String> requestData=new HashMap<String, String>();
		String path = request.getContextPath();
		String basePath = request.getScheme() + "://" + request.getServerName() + path + "/";
		
		CrowdOrderDataClass tmp=CrowdOrderCache.getInstance().loadOrderByID(CacheClass.getIntValue(orderid));
		
		/***银联全渠道系统，产品参数，除了encoding自行选择外其他不需修改***/
		requestData.put("version", DemoBase.version);   			  //版本号，全渠道默认值
		requestData.put("encoding", DemoBase.encoding_UTF8); 			  //字符集编码，可以使用UTF-8,GBK两种方式
		requestData.put("signMethod", "01");            			  //签名方法，只支持 01：RSA方式证书加密
		requestData.put("txnType", "01");               			  //交易类型 ，01：消费
		requestData.put("txnSubType", "01");            			  //交易子类型， 01：自助消费
		requestData.put("bizType", "000201");           			  //业务类型，B2C网关支付，手机wap支付
		requestData.put("channelType", "07");           			  //渠道类型，这个字段区分B2C网关支付和手机wap支付；07：PC,平板  08：手机
		
		/***商户接入参数***/
		requestData.put("merId", DemoBase.merId);    	          			  //商户号码，请改成自己申请的正式商户号或者open上注册得来的777测试商户号
		requestData.put("accessType", "0");             			  //接入类型，0：直连商户 
		requestData.put("orderId",tmp.order_sn.replace("-", ""));             //商户订单号，8-40位数字字母，不能含“-”或“_”，可以自行定制规则		
		requestData.put("txnTime", DemoBase.getCurrentTime());        //订单发送时间，取系统时间，格式为YYYYMMDDhhmmss，必须取当前时间，否则会报txnTime无效
		requestData.put("currencyCode", "156");         			  //交易币种（境内商户一般是156 人民币）		
		requestData.put("txnAmt", (int)(CacheClass.getFloatValue(tmp.totalrmb) * 100 )+ "");  //交易金额，单位分，不要带小数点
		requestData.put("reqReserved", tmp.orderid);        		      //请求方保留域，如需使用请启用即可；透传字段（可以实现商户自定义参数的追踪）本交易的后台通知,对本交易的交易状态查询交易、对账文件中均会原样返回，商户可以按需上传，长度为1-1024个字节		
		
		//前台通知地址 （需设置为外网能访问 http https均可），支付成功后的页面 点击“返回商户”按钮的时候将异步通知报文post到该地址
		//如果想要实现过几秒中自动跳转回商户页面权限，需联系银联业务申请开通自动返回商户权限
		//异步通知参数详见open.unionpay.com帮助中心 下载  产品接口规范  网关支付产品接口规范 消费交易 商户通知
		requestData.put("frontUrl", "http://newpay.91limao.com/"+DemoBase.frontUrl);
		
		//后台通知地址（需设置为【外网】能访问 http https均可），支付成功后银联会自动将异步通知报文post到商户上送的该地址，失败的交易银联不会发送后台通知
		//后台通知参数详见open.unionpay.com帮助中心 下载  产品接口规范  网关支付产品接口规范 消费交易 商户通知
		//注意:1.需设置为外网能访问，否则收不到通知    2.http https均可  3.收单后台通知后需要10秒内返回http200或302状态码 
		//    4.如果银联通知服务器发送通知后10秒内未收到返回状态码或者应答码非http200，那么银联会间隔一段时间再次发送。总共发送5次，每次的间隔时间为0,1,2,4分钟。
		//    5.后台通知地址如果上送了带有？的参数，例如：http://abc/web?a=b&c=d 在后台通知处理程序验证签名之前需要编写逻辑将这些字段去掉再验签，否则将会验签失败
		requestData.put("backUrl", "http://newpay.91limao.com/"+DemoBase.backUrl);
		
		/**请求参数设置完毕，以下对请求参数进行签名并生成html表单，将表单写入浏览器跳转打开银联页面**/
		Map<String, String> submitFromData = AcpService.sign(requestData,DemoBase.encoding_UTF8);  //报文中certId,signature的值是在signData方法中获取并自动赋值的，只要证书配置正确即可。
		
		String requestFrontUrl = SDKConfig.getConfig().getFrontRequestUrl();  //获取请求银联的前台地址：对应属性文件acp_sdk.properties文件中的acpsdk.frontTransUrl
		submitFromData.put("reqUrl", requestFrontUrl);
		
		
		return submitFromData;
	}	

	
	/** 全平仓  **/
	public static void toSellVrOrder(HttpServletRequest request,HttpServletResponse response){
		
		String userid=CacheClass.isLogin(request,response);
		if(CacheClass.isEmpty(userid))
		{
			return ;
		}
		CrowdUserAuthClass user=CrowdUserAuthCache.getInstance().getUser(CacheClass.getIntValue(userid));
		
		
		QueryModel queryParameters=new QueryModel();
		queryParameters.uid= CacheClass.getLongValue(user.uid);
		String jsonStr=JSON.toJSONString(queryParameters);
		
		
		ResultModel result=null;
		try {
			result=Api.buildRequest(CacheClass.getMwUrl()+"close_out",jsonStr);
		} catch (Exception e) {
			result=null;
			e.printStackTrace();
		}
		if(result==null || CacheClass.getIntValue(result.retcode)!=0) //失败
		{
			System.out.println("全平仓成功失败");
			if(result==null || CacheClass.isEmpty(result.data.szIoServerSn))
			{
				//inToVrSuccess(cdvrid,false);
				//throw new LzPluginException( "出错,入金失败,retcode=null");
			}
			else
			{
				//throw new LzPluginException( "出错,入金失败,retcode="+result.retcode+":"+result.GetRetMsg());
			}
		}
		else //成功 
		{
			
			System.out.println("全平仓成功");
			
		}
		
	}	



	public static void Temp20170515()
	{
		
		Connection con = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		try {

			con = DbConnectionManager.getConnection();
			//出金人
			List<vrsysrmb> outList=new ArrayList<vrsysrmb>();
			pstmt = con.prepareStatement("select * from vr_sys_rmb where time>1494844200000 and type=92 and rmb1!=0");
			rs=pstmt.executeQuery();
			while(rs.next())
			{
				vrsysrmb t1=new vrsysrmb();
				t1.id=rs.getInt("id");
				t1.userid=rs.getInt("userid");
				t1.rmb0=rs.getFloat("rmb0");
				t1.rmb1=rs.getFloat("rmb1");
				t1.time=rs.getLong("time");
				outList.add(t1);
			}
			if(outList.size()==0)
			{
				System.out.println("出错啦00");
				return; 
			}
			
			for(vrsysrmb t:outList)
			{
				//先取 上次入金 的数据
				DbConnectionManager.fastcloseStmt(rs,pstmt);
				pstmt = con.prepareStatement("select * from vr_sys_rmb where userid=? and time<? and type=93 and rmb1!=0 order by time desc limit 1");
				pstmt.setInt(1, t.userid);
				pstmt.setLong(2, t.time);
				rs=pstmt.executeQuery();
				vrsysrmb oldin=new vrsysrmb();
				if(rs.next())
				{
					oldin.userid=rs.getInt("userid");
					oldin.rmb0=rs.getFloat("rmb0");
					oldin.rmb1=rs.getFloat("rmb1");
				}
				else
				{
					System.out.println("出错啦11");
					return; 
				}
				//修正应得的豆豆值 
				DbConnectionManager.fastcloseStmt(rs,pstmt);
				float v=0;
				if(t.rmb1>oldin.rmb1)
				{
					v=t.rmb1-oldin.rmb1; //多扣的赠金 变为豆豆值
				}
				pstmt = con.prepareStatement("update cd_user_rmb set virtualcoin=virtualcoin+?  where userid=? ");
				pstmt.setFloat(1, v);
				pstmt.setInt(2, t.userid);
				pstmt.executeUpdate();
				
				//修正记录
				DbConnectionManager.fastcloseStmt(rs,pstmt);
				float rmb1=oldin.rmb1;
				if(t.rmb0<oldin.rmb1)
				{
					rmb1=t.rmb0;
				}
				pstmt = con.prepareStatement("update vr_sys_rmb set rmb1=?  where id=? ");
				pstmt.setFloat(1, rmb1);
				pstmt.setInt(2, t.id);
				pstmt.executeUpdate();
				 
				//修正vr_user_rmb  的残余 赠金值
				DbConnectionManager.fastcloseStmt(rs,pstmt);
				float vrcashgiftrmb3=0;
				if(oldin.rmb1>rmb1)
				{
					vrcashgiftrmb3=oldin.rmb1-rmb1;
				}
				pstmt = con.prepareStatement("update vr_user_rmb set vrcashgiftrmb3=?  where userid=? and netvalueRmb>0 ");
				pstmt.setFloat(1, vrcashgiftrmb3);
				pstmt.setInt(2, t.userid);
				pstmt.executeUpdate();
				
/*				//修正最大值
				DbConnectionManager.fastcloseStmt(rs,pstmt);
				pstmt = con.prepareStatement("update cd_user_rmb set maxvirtualcoin=maxvirtualcoin+?  where userid=? ");
				pstmt.setFloat(1, v);
				pstmt.setInt(2, t.userid);
				pstmt.executeUpdate();*/				
				
				//修正cd_sys_prestigelog   本次出金
				DbConnectionManager.fastcloseStmt(rs,pstmt);
				pstmt = con.prepareStatement("update cd_sys_prestigelog set logvalue=logvalue+?,newlogvalue=newlogvalue+?  where userid=? and cate=1 and type=3 and ctime>1494844200000 ");
				pstmt.setFloat(1, v);
				pstmt.setFloat(2, v);
				pstmt.setInt(3, t.userid);
				pstmt.executeUpdate();
				
				//修正cd_sys_prestigelog   本次出金后的修正
				DbConnectionManager.fastcloseStmt(rs,pstmt);
				pstmt = con.prepareStatement("update cd_sys_prestigelog set newlogvalue=newlogvalue+?  where userid=? and cate=1 and type!=3 and  ctime>? ");
				pstmt.setFloat(1, v);
				pstmt.setInt(2, t.userid);
				pstmt.setLong(3, t.time);
				pstmt.executeUpdate();	

			}
			

			
			//入金人
			List<vrsysrmb> inList=new ArrayList<vrsysrmb>();
			DbConnectionManager.fastcloseStmt(rs,pstmt);
			pstmt = con.prepareStatement("select * from vr_sys_rmb where time>1494844200000 and type=93 and rmb1!=0");
			rs=pstmt.executeQuery();
			while(rs.next())
			{
				vrsysrmb t1=new vrsysrmb();
				t1.id=rs.getInt("id");
				t1.userid=rs.getInt("userid");
				t1.rmb0=rs.getFloat("rmb0");
				t1.rmb1=rs.getFloat("rmb1");
				inList.add(t1);
			}
			//
			for(vrsysrmb t:inList)
			{
				DbConnectionManager.fastcloseStmt(rs,pstmt);
				pstmt = con.prepareStatement("update vr_user_rmb set vrcashgiftrmb3=0  where userid=? ");
				pstmt.setInt(1, t.userid);
				pstmt.executeUpdate();
			}
			System.out.println("完成");
	
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("出错");
		} finally {
			DbConnectionManager.closeConnection(rs, pstmt, con);
		}
		
		
		
		
		
	}

	
	public static int getSysTest() 
	{
		return CacheClass.getIntValue(BaseDataCacheManager.getInstance().Load_Param("sysTest"));

	}
	
	public static Map<String,String>  getRequest(HttpServletRequest request)
	{
		 Map<String,String> resultMap = null;
		byte[] bytes = new byte[1024 * 1024];
        InputStream is = null;
        try {
            is = request.getInputStream();
            int nRead = 1;
            int nTotalRead = 0;
            while (nRead > 0) {
                nRead = is.read(bytes, nTotalRead, bytes.length - nTotalRead);
                if (nRead > 0)
                    nTotalRead = nTotalRead + nRead;
            }
            String res = new String(bytes, 0, nTotalRead, "utf-8");
            System.out.println("res=" + res);
            if(!CacheClass.isEmpty(res))
            {
				try {
					resultMap = XmlUtils.xml2map(res, "xml");
				} catch (DocumentException e) {
					e.printStackTrace();
				}
			}
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
        	if(is!=null)
        	{
				try {
					is.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
        	}
            is = null;
		 }
        return resultMap;
        
	}
	
	public static byte[] getReturnByte(String return_code) 
	{
		SortedMap<String, String> map = new TreeMap<String, String>();
		map.put("return_code", return_code);
		
		Map<String,String> params = SignUtils.paraFilter(map);
        StringBuilder buf = new StringBuilder((params.size() +1) * 10);
        SignUtils.buildPayParams(buf,params,false);
        String preStr = buf.toString();
        String sign = MD5.sign(preStr, "&key=" + CorefireConfig.getKey(), "utf-8").toUpperCase();
        map.put("sign", sign);
        
		byte[] data = null;
		try {
			String re=XmlUtils.parseXML(map);
			System.out.println("返回结果="+re);
			data = re.getBytes("utf-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return data;
	}
	
	public static String getReturnString(String return_code) 
	{
		SortedMap<String, String> map = new TreeMap<String, String>();
		map.put("return_code", return_code);
		Map<String,String> params = SignUtils.paraFilter(map);
        StringBuilder buf = new StringBuilder((params.size() +1) * 10);
        SignUtils.buildPayParams(buf,params,false);
        String preStr = buf.toString();
        String sign = MD5.sign(preStr, "&key=" + CorefireConfig.getKey(), "utf-8").toUpperCase();
        map.put("sign", sign);
        String re=XmlUtils.parseXML(map);
		return re;
		
		
	}
	
	public static void tradeReg(HttpServletRequest request,HttpServletResponse response) 
	{
		String useridStr=CacheClass.isLogin(request,response);
		if(CacheClass.isEmpty(useridStr))
		{
			return;
		}

		QueryJWModelData querData=new QueryJWModelData();
		
		querData.Name = "姓名";//姓名
		querData.Type = "3";//交易商类型 1：企业2：代理3：个人
		querData.ContactMan = "联系人";//联系人
		querData.CertificateType = "1";//证件类型 1：居民身份证2：士官证3：学生证4：驾驶证5：护照6：港澳通行证
		querData.CertificateNo = "420111198810255796";//证件号码
		querData.Mobile = "15907884064";//联系人手机号
		querData.Bank = "005";//开户银行12：中行13：建行15：招行18：平安005：农行
		querData.BankAccount = "6222082103000758414";//银行帐号
		querData.Address = "地址地址地址";//地址
		querData.Email = "wfwfw@dd.com";//Email
		querData.BrokerId = "z03";//开户机构 z03    居间商可以不填
		//querData.BrokerAgeId = "";//居间商
		querData.Picture = "01010101010101011010110";//身份证正面照	
				
		String userid=useridStr;
		
		try {
			CrowdUserAuthProvider.getInstance().openAuthForTradeUser(userid,querData);
		} catch (LzPluginException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
	
	public static void AutoInVrPreOrder()
	{
		CrowdOrderProvider.getInstance().AutoInVrPreOrder();
		/*
		Calendar orderTime = Calendar.getInstance();
		orderTime.setTime(new Date());
		orderTime.set(Calendar.HOUR_OF_DAY, 0);
		orderTime.set(Calendar.MINUTE, 0);
		orderTime.set(Calendar.SECOND, 0);  
		orderTime.set(Calendar.MILLISECOND, 0);
		Date orderDate = orderTime.getTime();
		CrowdOrderCache.getInstance().AutoCheckCdOrder(orderDate);
		*/
	}
	
	
}
